<?php
/**
 * Created by PhpStorm.
 * User: mr.lee
 * Date: 2018/6/6
 * Time: 下午4:57
 */

namespace app\apitemp\controller;

use app\common\model\CardConsume;
use app\common\model\CardGeneral;
use app\common\model\CardUserBonus;
use app\common\model\CardUserFee;
use app\common\model\CardUserGet;
use app\common\model\Paylog;
use app\common\model\Tklog;

class Statis extends Pub
{
    //交易记录

    public function paylog($param)
    {
        try {
            $Pay = new Paylog();
            $page = ($param['page'] - 1) * 10;
            $start_time = strtotime($param['start_time']);
            $end_time = strtotime($param['end_time']);
            $map['a.pay_statu'] = array('in', '1,2,3');
            $map['a.mid'] = $param['merchantid'];
            if ($start_time == "" && $end_time == "") {
                $map['a.add_time'] = array(array('egt', 0), array('elt', time()), 'and');
            } elseif ($start_time !== "" && $end_time == "") {
                $map['a.add_time'] = array(array('egt', $start_time), array('elt', time()), 'and');
            } elseif ($start_time == "" && $end_time !== "") {
                $map['a.add_time'] = array(array('egt', 0), array('elt', $end_time), 'and');
            } else {
                $map['a.add_time'] = array(array('egt', $start_time), array('elt', $end_time), 'and');
            }
            $paylog = $Pay->alias('a')
                ->join('wn_merchant b', 'b.id=a.mid')
                ->where($map)
                ->field('b.merchant as merchantname,a.orderid as out_trade_no,a.price as total_fee,a.add_time as end_time,a.pay_fs as channel,a.tk_price as refund_fee,a.service_charge,cashier,d_cashier')
                ->order('a.add_time desc')
                ->limit($page, 10)->select();
            if ($paylog) {
                foreach ($paylog as $k => $v) {
                    $paylog[$k]['end_time'] = date('Y-m-d H:i:s', $v['end_time']);
                    $paylog[$k]['deivce_id'] = !empty($v['cashier']) ? $v['cashier'] : $v['d_cashier'];
                    unset($paylog[$k]['cashier']);
                    unset($paylog[$k]['d_cashier']);
                }
                $rarr['return_code'] = "SUCCESS";
                $rarr['return_msg'] = "";
                $rarr['result_code'] = 'SUCCESS';
                $rarr['result_msg'] = "获取成功";
                $rarr['info'] = $paylog;
            } else {
                $rarr['return_code'] = "SUCCESS";
                $rarr['return_msg'] = "";
                $rarr['result_code'] = 'FAIL';
                $rarr['result_msg'] = "没有查询到相关记录";
            }

        } catch (\Exception $e) {

            $rarr['return_code'] = "FAIL";
            $rarr['return_msg'] = "系统错误" . $e->getMessage();
            $rarr['result_code'] = 'FAIL';
            $rarr['result_msg'] = "系统错误" . $e->getMessage();
        }
        return $rarr;
    }

    //交易统计
    public function paycount($param)
    {
        try {
            $Pay = new Paylog();
            $start_time = strtotime($param['start_time']);
            $end_time = strtotime($param['end_time']);
            $mae['mid'] = $param['merchantid'];
            if ($start_time == "" && $end_time == "") {

                $mae['add_time'] = array(array('egt', 0), array('elt', time()), 'and');
            } elseif ($start_time !== "" && $end_time == "") {
                $mae['add_time'] = array(array('egt', $start_time), array('elt', time()), 'and');
            } elseif ($start_time == "" && $end_time !== "") {
                $mae['add_time'] = array(array('egt', 0), array('elt', $end_time), 'and');
            } else {
                $mae['add_time'] = array(array('egt', $start_time), array('elt', $end_time), 'and');
            }

            $map = $mae;
            $map['pay_statu'] = 1;
            $mao = $mae;
            $mao['pay_statu'] = array('in', '2,3');
            //     return json_encode($data);
            $pay['wx_online_count'] = $Pay->where($map)->where(array('pay_fs' => 0))->count('id');
            $pay['wx_online_fee'] = $Pay->where($map)->where(array('pay_fs' => 0))->sum('price');
            $pay['ali_online_count'] = $Pay->where($map)->where(array('pay_fs' => 1))->count('id');
            $pay['ali_online_fee'] = $Pay->where($map)->where(array('pay_fs' => 1))->sum('price');
            //微信退款
            $pay['wx_tk_count'] = $Pay->where($mao)->where(array('pay_fs' => 2))->count('id');

            $pay['wx_tk_fee'] = $Pay->where($mao)->where(array('pay_fs' => 2))->sum('tk_price');

            //支付宝退款
            $pay['ali_tk_count'] = $Pay->where($mao)->where(array('pay_fs' => 3))->count('id');
            $pay['ali_tk_fee'] = $Pay->where($mao)->where(array('pay_fs' => 3))->sum('tk_price');
            //微信刷卡收款
            $pay['wx_barcode_count'] = $Pay->where($map)->where(array('pay_fs' => 2))->count('id');
            $pay['wx_barcode_fee'] = $Pay->where($map)->where(array('pay_fs' => 2))->sum('price');
            //阿里刷卡收款
            $pay['ali_barcode_count'] = $Pay->where($map)->where(array('pay_fs' => 3))->count('id');
            $pay['ali_barcode_fee'] = $Pay->where($map)->where(array('pay_fs' => 3))->sum('price');
            //现金支付
            $pay['point_count'] = $Pay->where($map)->where(array('pay_fs' => 4))->count('id');
            $pay['point_fee'] = $Pay->where($map)->where(array('pay_fs' => 4))->sum('price');
            //微信会员卡
            $pay['wx_card_count'] = $Pay->where($map)->where(array('pay_fs' => 8))->count('id');
            $pay['wx_card_fee'] = $Pay->where($map)->where(array('pay_fs' => 8))->sum('price');
            //pos刷卡
            $pay['pos_count'] = $Pay->where($map)->where(array('pay_fs' => 5))->count('id');
            $pay['pos_fee'] = $Pay->where($map)->where(array('pay_fs' => 5))->sum('price');
            $rarr['return_code'] = "SUCCESS";
            $rarr['return_msg'] = "";
            $rarr['result_code'] = 'SUCCESS';
            $rarr['result_msg'] = "获取成功";
            $rarr['info'] = $pay;
        } catch (\Exception $e) {
            $rarr['return_code'] = "FAIL";
            $rarr['return_msg'] = "系统错误" . $e->getMessage();
            $rarr['result_code'] = 'FAIL';
            $rarr['result_msg'] = "系统错误" . $e->getMessage();
        }
        return $rarr;
    }

    public function paystatis($param)
    {
        try {
            $Paylog = new Paylog();
            $Tklog = new Tklog();
            $start_time = strtotime($param['start_time']);
            $end_time = strtotime($param['end_time']);
            if ($end_time - $start_time > 31 * 60 * 60 * 24) {
                $rarr['return_code'] = "SUCCESS";
                $rarr['return_msg'] = "";
                $rarr['result_code'] = 'FAIL';
                $rarr['result_msg'] = "查询间隔不能大于31天";

                return $rarr;
            }
            if ($start_time == "" && $end_time == "") {
                $map['a.add_time'] = array(array('egt', 0), array('elt', time()), 'and');
            } elseif ($start_time !== "" && $end_time == "") {
                $map['a.add_time'] = array(array('egt', $start_time), array('elt', time()));
            } elseif ($start_time == "" && $end_time !== "") {
                $map['a.add_time'] = array(array('egt', 0), array('elt', $end_time));
            } else {
                $map['a.add_time'] = array(array('egt', $start_time), array('elt', $end_time));
            }
            $map['a.pay_cate'] = array('neq', "recharge");
            $mids = $param['merchantid'];
            $map['a.mid'] = $mids;
            $subsql = $Tklog->field('orderid,sum(refund_fee) as refund_fee,id')->group('orderid')->buildSql();

            $maptk['addtime'] = array(array('egt', $start_time), array('elt', $end_time), "and");
            $maptk['mid'] = $mids;
            $map['a.pay_statu'] = array(array('neq', 0), array('neq', 8), 'and');
            $map['a.pay_cate'] = array('neq', 'recharge');
            //微信支付
            $map1 = $map;
            $map1['a.pay_fs'] = array('in', [0, 2]);
            $arrwx = $Paylog->alias('a')->join([$subsql => 'b'], 'a.orderid=b.orderid', 'left')->where($map1)->field('sum(b.refund_fee) as wx_refund_fee,count(b.id) as wx_refund_order,count(a.id) as wx_order,sum(a.price) as wx_real_fee,sum(a.yf_price) as wx_ought_fee,sum(a.zk_price) as wx_dis_fee,sum(a.service_charge) as wx_service_charge')->find();
            $arr['wx_order'] = $arrwx['wx_order'];                //微信笔数
            $wx_real_fee = $arrwx['wx_real_fee'] - $arrwx['wx_refund_fee'];
            $arr['wx_real_fee'] = number_format($wx_real_fee, 2);         //微信实收金额
            $arr['wx_dis_fee'] = number_format($arrwx['wx_dis_fee'], 2);        //微信折扣金额
            $arr['wx_ought_fee'] = number_format($arrwx['wx_ought_fee'], 2);          //微信应收金额
            $arr['wx_refund_fee'] = number_format($arrwx['wx_refund_fee'], 2);         //微信退款金额
            $arr['wx_refund_order'] = $arrwx['wx_refund_order'];//微信退款单数
            $arr['wx_service_charge'] = $arrwx['wx_service_charge'];//微信退款单数

            //支付宝支付
            $map3 = $map;
            $map3['a.pay_fs'] = array('in', [1, 3]);
            $arrali = $Paylog->alias('a')->join([$subsql => 'b'], 'a.orderid=b.orderid', 'left')->where($map3)->field('sum(b.refund_fee) as ali_refund_fee,count(b.id) as ali_refund_order,count(a.id) as ali_order,sum(a.price) as ali_real_fee,sum(a.yf_price) as ali_ought_fee,sum(a.zk_price) as ali_dis_fee,sum(a.service_charge) as ali_service_charge')->find();
            $arr['ali_order'] = $arrali['ali_order'];               //支付宝笔数
            $ali_real_fee = $arrali['ali_real_fee'] - $arrali['ali_refund_fee'];
            $arr['ali_real_fee'] = number_format($ali_real_fee, 2);         //支付宝实收金额
            $arr['ali_dis_fee'] = number_format($arrali['ali_dis_fee'], 2);        //支付宝折扣金额
            $arr['ali_ought_fee'] = number_format($arrali['ali_ought_fee'], 2);          //支付宝应收金额
            $arr['ali_refund_fee'] = number_format($arrali['ali_refund_fee'], 2);         //支付宝退款金额
            $arr['ali_refund_order'] = $arrali['ali_refund_order'];//支付宝退款单数
            $arr['ali_service_charge'] = $arrali['ali_service_charge'];//支付宝退款单数

            //会员卡支付
            $map5 = $map;
            $map5['a.pay_fs'] = 8;
            $arrwxcard = $Paylog->alias('a')->join([$subsql => 'b'], 'a.orderid=b.orderid', 'left')->where($map5)->field('sum(b.refund_fee) as wx_card_refund_fee,count(b.id) as wx_card_refund_order,count(a.id) as wx_card_order,sum(a.price) as wx_card_real_fee,sum(a.yf_price) as wx_card_ought_fee,sum(a.zk_price) as wx_card_dis_fee')->find();

            $arr['wx_card_order'] = $arrwxcard['wx_card_order'];                       //会员卡笔数
            $wx_card_real_fee = $arrwxcard['wx_card_real_fee'] - $arrwxcard['wx_card_refund_fee'];
            $arr['wx_card_real_fee'] = number_format($wx_card_real_fee, 2);         //会员卡实收金额
            $arr['wx_card_dis_fee'] = number_format($arrwxcard['wx_card_dis_fee'], 2);        //会员卡折扣金额
            $arr['wx_card_ought_fee'] = number_format($arrwxcard['wx_card_ought_fee'], 2);          //会员卡应收金额
            $arr['wx_card_refund_fee'] = number_format($arrwxcard['wx_card_refund_fee'], 2);         //会员卡退款金额
            $arr['wx_card_refund_order'] = $arrwxcard['wx_card_refund_order'];//会员卡退款单数

            //现金支付
            $map6 = $map;
            $map6['a.pay_fs'] = 4;
            $arrcash = $Paylog->alias('a')->join([$subsql => 'b'], 'a.orderid=b.orderid', 'left')->where($map6)->field('sum(b.refund_fee) as cash_refund_fee,count(b.id) as cash_refund_order,count(a.id) as cash_order,sum(a.price) as cash_real_fee,sum(a.yf_price) as cash_ought_fee,sum(a.zk_price) as cash_dis_fee')->find();

            $arr['cash_order'] = $arrcash['cash_order'];                      //现金订单数
            $cash_real_fee = $arrcash['cash_real_fee'] - $arrcash['cash_refund_fee'];
            $arr['cash_real_fee'] = number_format($cash_real_fee, 2);         //会员卡实收金额
            $arr['cash_dis_fee'] = number_format($arrcash['cash_dis_fee'], 2);        //会员卡折扣金额
            $arr['cash_ought_fee'] = number_format($arrcash['cash_ought_fee'], 2);          //会员卡应收金额
            $arr['cash_refund_fee'] = number_format($arrcash['cash_refund_fee'], 2);         //会员卡退款金额
            $arr['cash_refund_order'] = $arrcash['cash_refund_order'];//会员卡退款单数
            //pos
            $map7 = $map;
            $map7['a.pay_fs'] = 5;
            $arrpos = $Paylog->alias('a')->join([$subsql => 'b'], 'a.orderid=b.orderid', 'left')->where($map7)->field('sum(b.refund_fee) as pos_refund_fee,count(b.id) as pos_refund_order,count(a.id) as pos_order,sum(a.price) as pos_real_fee,sum(a.yf_price) as pos_ought_fee,sum(a.zk_price) as pos_dis_fee,sum(service_charge) as pos_service_charge')->find();

            $arr['pos_order'] = $arrpos['pos_order'];                      //现金订单数
            $pos_real_fee = $arrpos['pos_real_fee'] - $arrpos['pos_refund_fee'];
            $arr['pos_real_fee'] = number_format($pos_real_fee, 2);         //会员卡实收金额
            $arr['pos_dis_fee'] = number_format($arrpos['pos_dis_fee'], 2);        //会员卡折扣金额
            $arr['pos_ought_fee'] = number_format($arrpos['pos_ought_fee'], 2);          //会员卡应收金额
            $arr['pos_refund_fee'] = number_format($arrpos['pos_refund_fee'], 2);         //会员卡退款金额
            $arr['pos_refund_order'] = $arrpos['pos_refund_order'];//会员卡退款单数
            $arr['pos_service_charge'] = $arrpos['pos_service_charge'];//会员卡退款单数

//          //合计


            $arrs = $Tklog->where($maptk)->field('sum(refund_fee) as refund_fee,count(id) as refund_order')->find();
            $arr['refund_order'] = $arrs['refund_order'];        //总退款数
            $arr['refund_fee'] = !empty($arrs['refund_fee']) ? $arrs['refund_fee'] : "0.00";          //总退款
            $map7 = $map;
            $map7['a.pay_fs'] = array('in', [0, 1, 2, 3, 4, 5, 8]);
            $z_arr = $Paylog->alias('a')->where($map7)->field('sum(price) as real_fee,sum(service_charge) as service_charge,count(id) as real_order,sum(yf_price) as ought_fee,sum(zk_price) as dis_fee,avg(price) as avg_fee')->find();
            $real_fee = (string)($z_arr['real_fee'] - $arr['refund_fee']);
            $arr['real_fee'] = number_format($real_fee, 2);
            $arr['order'] = $z_arr['real_order'];
            $arr['dis_fee'] = number_format($z_arr['dis_fee'], 2);                             //总实收金额
            $arr['ought_fee'] = number_format($z_arr['ought_fee'], 2);          //总应付
            $arr['avg_fee'] = number_format($z_arr['avg_fee'], 2);                       //总平均
            $arr['service_charge'] = number_format($z_arr['service_charge'], 2);                       //总平均

            $rarr['return_code'] = "SUCCESS";
            $rarr['return_msg'] = "";
            $rarr['result_code'] = 'SUCCESS';
            $rarr['result_msg'] = "获取成功";
            $rarr['info'] = $arr;
        } catch (\Exception $e) {
            $rarr['return_code'] = "FAIL";
            $rarr['return_msg'] = "系统错误" . $e->getMessage();
            $rarr['result_code'] = 'FAIL';
            $rarr['result_msg'] = "系统错误" . $e->getMessage();
        }
        return $rarr;
    }

    //交易统计
    public function banjie($param)
    {
        try {
            $start_time = strtotime($param['start_time']);
            $end_time = strtotime($param['end_time']);
            if ($start_time == "" && $end_time == "") {
                $map['a.add_time'] = array(array('egt', 0), array('elt', time()), 'and');
            } elseif ($start_time !== "" && $end_time == "") {
                $map['a.add_time'] = array(array('egt', $start_time), array('elt', time()));
            } elseif ($start_time == "" && $end_time !== "") {
                $map['a.add_time'] = array(array('egt', 0), array('elt', $end_time));
            } else {
                $map['a.add_time'] = array(array('egt', $start_time), array('elt', $end_time));
            }
            $map['a.pay_statu']=array(array('neq', 0), array('neq', 8), 'and');
            $map['a.kuantai']=$param['kuantai'];
            $map['a.d_cashier']=$param['device_id'];
            $mids = $param['merchantid'];
            $map['a.mid'] = $mids;
            $maptk['addtime'] = array(array('egt', $start_time), array('elt', $end_time), "and");
            $maptk['mid'] = $mids;
            $maptk['action_user'] = $param['device_id'];
            $Tklog = new Tklog();
            $Paylog = new Paylog();
            $arrs = $Tklog->where($maptk)->field('sum(refund_fee) as refund_fee,count(id) as refund_order')->find();
            $arr['refund_order'] = $arrs['refund_order'];        //总退款数
            $arr['refund_fee'] = !empty($arrs['refund_fee']) ? $arrs['refund_fee'] : "0.00";          //总退款
            $map7 = $map;
            $map7['a.pay_fs'] = array('in', [0, 1, 2, 3, 4, 5, 8]);
            $z_arr = $Paylog->alias('a')->where($map7)->field('sum(price) as real_fee,sum(service_charge) as service_charge,count(id) as real_order,sum(yf_price) as ought_fee,sum(zk_price) as dis_fee,avg(price) as avg_fee')->find();
            $real_fee = (string)($z_arr['real_fee'] - $arr['refund_fee']);
            $arr['real_fee'] = number_format($real_fee, 2);
            $arr['order'] = $z_arr['real_order'];
            $arr['dis_fee'] = number_format($z_arr['dis_fee'], 2);                             //总实收金额
            $arr['ought_fee'] = number_format($z_arr['ought_fee'], 2);          //总应付

            $rarr['return_code'] = "SUCCESS";
            $rarr['return_msg'] = "";
            $rarr['result_code'] = 'SUCCESS';
            $rarr['result_msg'] = "获取成功";
            $rarr['info'] = $arr;
        } catch (\Exception $e) {
            $rarr['return_code'] = "FAIL";
            $rarr['return_msg'] = "系统错误" . $e->getMessage();
            $rarr['result_code'] = 'FAIL';
            $rarr['result_msg'] = "系统错误" . $e->getMessage();
        }
        return $rarr;
    }

    //卡券核销统计
    public function cardqstatis($param)
    {
        try {
            $map['mid'] = $param['merchantid'];
            if (!empty($param['cardq_id'])) {
                $CardGeneral = new CardGeneral();
                $map['card_id'] = $CardGeneral->where('id', $param['cardq_id'])->value('card_id');
            }
            $start_time = strtotime($param['start_time']);
            $end_time = strtotime($param['end_time']);
            if ($start_time == "" && $end_time == "") {
                $map['create_time'] = array(array('egt', 0), array('elt', time()), 'and');
            } elseif ($start_time !== "" && $end_time == "") {
                $map['create_time'] = array(array('egt', $start_time), array('elt', $end_time), 'and');
            } elseif ($start_time == "" && $end_time !== "") {
                $map['create_time'] = array(array('egt', 0), array('elt', $end_time));
            } else {
                $map['create_time'] = array(array('egt', $start_time), array('elt', $end_time));
            }
            $CardConsume = new CardConsume();
            $count = $CardConsume->where($map)->count('id');
            $rarr['return_code'] = "SUCCESS";
            $rarr['return_msg'] = "";
            $rarr['result_code'] = 'SUCCESS';
            $rarr['result_msg'] = "获取成功";
            $rarr['info'] = ['ret_num' => $count];
        } catch (\Exception $e) {
            $rarr['return_code'] = "FAIL";
            $rarr['return_msg'] = "系统错误" . $e->getMessage();
            $rarr['result_code'] = 'FAIL';
            $rarr['result_msg'] = "系统错误" . $e->getMessage();
        }
        return $rarr;
    }

    //会员卡消费充值统计
    public function cardstatis($param)
    {
        try {
            $CardUserGet = new CardUserGet();
            $CardUserFee = new CardUserFee();
            $CardUserBonus = new CardUserBonus();
            $map['mid'] = $param['merchantid'];
            $start_time = strtotime($param['start_time']);
            $end_time = strtotime($param['end_time']);
            $mae['mid'] = $param['merchantid'];
            if ($start_time == "" && $end_time == "") {
                $map['create_time'] = array(array('egt', 0), array('elt', time()), 'and');
            } elseif ($start_time !== "" && $end_time == "") {
                $map['create_time'] = array(array('egt', $start_time), array('elt', $end_time), 'and');
            } elseif ($start_time == "" && $end_time !== "") {
                $map['create_time'] = array(array('egt', 0), array('elt', $end_time));
            } else {
                $map['create_time'] = array(array('egt', $start_time), array('elt', $end_time));
            }
            $re_data['add_member'] = $CardUserGet->where($map)->where(['have' => 1, 'fire' => 1])->count('id');//新增会员
            $re_data['rec_fee'] = number_format($CardUserFee->where($map)->where(['type' => 1])->sum('num'), 2);//充值到账金额
            $re_data['rec_bonus'] = number_format($CardUserBonus->where(['type' => 1])->where($map)->sum('num'), 2);//新增积分
            $re_data['ret_bonus'] = number_format($CardUserBonus->where(['type' => 2])->where($map)->sum('num'), 2);//消费积分

            $recs = $CardUserFee->where($map)->where(['type' => 1, 'cate' => 1])->field('count(id) as rec_order,sum(num) as rec_ought_fee')->find();
            $re_data['rec_order'] = number_format($recs['rec_order'], 2);//充值笔数
            $re_data['rec_ought_fee'] = number_format($recs['rec_ought_fee'], 2);//实充金额
            $recs2 = $CardUserFee->where($map)->where(['type' => 1, 'cate' => ['neq', 1]])->field('sum(num) as rec_give_fee')->find();
            $re_data['rec_give_fee'] = number_format($recs2['rec_give_fee'], 2);//赠送金额
            //渠道统计
            //微信
            $wx_c = $CardUserFee->where($map)->where(['type' => 1, 'cate' => 1, 'pay_cate' => 2])->field('count(id) as rec_order,sum(num) as rec_ought_fee')->find();
            $wx_z = $CardUserFee->where($map)->where(['type' => 1, 'cate' => ['neq', 1], 'pay_cate' => 2])->field('sum(num) as rec_give_fee')->find();
            //支付宝
            $ali_c = $CardUserFee->where($map)->where(['type' => 1, 'cate' => 1, 'pay_cate' => 3])->field('count(id) as rec_order,sum(num) as rec_ought_fee')->find();
            $ali_z = $CardUserFee->where($map)->where(['type' => 1, 'cate' => ['neq', 1], 'pay_cate' => 3])->field('sum(num) as rec_give_fee')->find();
            //现金
            $cash_c = $CardUserFee->where($map)->where(['type' => 1, 'cate' => 1, 'pay_cate' => 4])->field('count(id) as rec_order,sum(num) as rec_ought_fee')->find();
            $cash_z = $CardUserFee->where($map)->where(['type' => 1, 'cate' => ['neq', 1], 'pay_cate' => 4])->field('sum(num) as rec_give_fee')->find();
            //微信
            $online_c = $CardUserFee->where($map)->where(['type' => 1, 'cate' => 1, 'pay_cate' => ['in', '0,1']])->field('count(id) as rec_order,sum(num) as rec_ought_fee')->find();
            $online_z = $CardUserFee->where($map)->where(['type' => 1, 'cate' => ['neq', 1], 'pay_cate' => ['in', '0,1']])->field('sum(num) as rec_give_fee')->find();

            $re_data['wx_rec_order'] = $wx_c['rec_order'];//微信充值笔数
            $re_data['wx_rec_ought_fee'] = number_format($wx_c['rec_ought_fee'], 2);//微信实充金额
            $re_data['wx_rec_give_fee'] = number_format($wx_z['rec_give_fee'], 2);//微信赠送金额
            $re_data['ali_rec_order'] = $ali_c['rec_order'];//支付宝充值笔数
            $re_data['ali_rec_ought_fee'] = number_format($ali_c['rec_ought_fee'], 2);//支付宝实充金额
            $re_data['ali_rec_give_fee'] = number_format($ali_z['rec_give_fee'], 2);//支付宝赠送金额
            $re_data['cash_rec_order'] = $cash_c['rec_order'];//现金充值笔数
            $re_data['cash_rec_ought_fee'] = number_format($cash_c['rec_ought_fee'], 2);//现金实充金额
            $re_data['cash_rec_give_fee'] = number_format($cash_z['rec_give_fee'], 2);//现金赠送金额
            $re_data['online_rec_order'] = $online_c['rec_order'];//自助充值笔数
            $re_data['online_rec_ought_fee'] = number_format($online_c['rec_ought_fee'], 2);//自助实充金额
            $re_data['online_rec_give_fee'] = number_format($online_z['rec_give_fee'], 2);//自助赠送金额
            $rarr['return_code'] = "SUCCESS";
            $rarr['return_msg'] = "";
            $rarr['result_code'] = 'SUCCESS';
            $rarr['result_msg'] = "获取成功";
            $rarr['info'] = $re_data;
        } catch (\Exception $e) {
            $rarr['return_code'] = "FAIL";
            $rarr['return_msg'] = "系统错误" . $e->getMessage();
            $rarr['result_code'] = 'FAIL';
            $rarr['result_msg'] = "系统错误" . $e->getMessage();
        }
        return $rarr;


    }

}